import type {
  goodsSpuData,
  AddFavoriteData,
  FavoriteResData,
  UpdateCartData,
  UpdateOrderData,
  CreateOrderData,
} from '@/types/goods'
import { http } from '@/utils/http'

export default {
  getSkuGoodsDetailApi: (id_: string) => {
    //获取商品详情Sku
    return http<goodsSpuData>({
      method: 'GET',
      url: '/v1/shop/goods/queryGoodsDetailById/' + id_,
    })
  },
  getSpuGoodsDetailApi: (id_: string) => {
    //获取商品SPU详情
    return http<goodsSpuData>({
      method: 'GET',
      url: '/v1/shop/goods/noAuth/getGoodsById/' + id_,
    })
  },
  addGoodsFavorite: (params: AddFavoriteData) => {
    return http<FavoriteResData>({
      method: 'POST',
      url: '/v1/shop/goodsFavorite/addGoodsFavorite',
      data: params,
    })
  },
  delGoodsFavorite: (params: AddFavoriteData) => {
    return http<null>({
      method: 'POST',
      url: '/v1/shop/goodsFavorite/deleteGoodsFavorite',
      data: params,
    })
  },
  updateCartApi: (data: UpdateCartData[]) => {
    return http<any>({
      method: 'POST',
      url: `/v1/shop/cart/updateForWeb`,
      header: {
        'Content-Type': 'application/json;charset=utf-8',
      },
      data: data,
    })
  },
  updateCartByProductListApi: (data: UpdateOrderData[]) => {
    return http<CreateOrderData>({
      method: 'POST',
      url: `/v1/shop/pisen/cart/updateCartByProductList`,
      header: {
        'Content-Type': 'application/json;charset=utf-8',
      },
      data: data,
    })
  },
}
